'''
Created on 2010-04-03

@author: Jarek
'''
from processors.git_repo_scanner import GitRepoScanner
from processors.mercurial_repo_scanner import MercurialRepoScanner
from processors.subversion_repo_scanner import SubversionRepoScanner

class ScannerFactory: #pylint: disable-msg=R0903
    """
    Creates appropriate scanner based on its type.
    """
    def __init__(self, settings, storepath, oldpath):
        """
        Creates scanner
        settings: configuration settings
        storepath: path where all processed ids are stored
        oldpath: path where old ids are stored
        """
        self._storepath = storepath
        self._oldpath = oldpath
        self._settings = settings

    def get_scanner(self, repo_type, name):
        """
        Get scanner based on repo_type and name
        repo_type: type of the repository (hg, svn, git currently)
        name: name of the repository
        """
        if repo_type == "hg":
            return MercurialRepoScanner(self._settings, \
                            self._storepath, self._oldpath, name)
        elif repo_type == "git":
            return GitRepoScanner(self._settings, \
                            self._storepath, self._oldpath, name)
        elif repo_type == "svn":
            return SubversionRepoScanner(self._settings, \
                            self._storepath, self._oldpath, name)
        return None
